using System;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

namespace Darilek.SandcastleExtensions.PlugIns.Configuration
{
	
	[XmlRoot("configuration", Namespace = "")]
	public class ResolveReferencePlugInConfiguration : PlugInConfigurationBase
	{
		private Collection<TargetItem> _targets = new Collection<TargetItem>();

		public ResolveReferencePlugInConfiguration()
			: base()
		{
		}

		[XmlArray("targets")]
		[XmlArrayItem("target")]
		public Collection<TargetItem> Targets
		{
			get { return _targets; }
		}
	}

	public class TargetItem
	{
		private string _baseDir;
		private string _files;
		private bool _recurse;
		private bool _active;

		public TargetItem() : this(string.Empty, string.Empty, false) { }

		public TargetItem(string directory, string files, bool recurse)
		{
			_baseDir = directory;
			_files = files;
			_recurse = recurse;
			_active = true;
		}

		[XmlAttribute("files")]
		public string Files
		{
			get { return _files; }
			set { _files = value; }
		}

		[XmlAttribute("base")]
		public string BaseDir
		{
			get { return _baseDir; }
			set { _baseDir = value; }
		}

		[XmlAttribute("type")]
		public string LinkType
		{
			get { return "Index"; }
			set { }	// just for proper serialization
		}

		[XmlAttribute("recurse")]
		public bool Recurse
		{
			get { return _recurse; }
			set { _recurse = value; }
		}

		[XmlAttribute("active")]
		public bool Active
		{
			get { return _active; }
			set { _active = value; }
		}

		[XmlIgnore()]
		public string DisplayPath
		{
			get 
			{
				string result = this.BaseDir;
				if (String.IsNullOrEmpty(result))
				{
					return this.Files;
				}
				else
				{
					return this.BaseDir + @"\" + this.Files;
				}
			}
		}


	}
	
}
